const http = require('http')
const url = require('url')

const server = http.createServer((request, response) => {
  response.setHeader('Content-Type', 'text/html;charset=utf-8')

  if(request.method === 'GET' && url.parse(request.url).pathname === '/login') {
    response.end('登录页面')
    return
  }

  let urlObj = new URL(request.url, 'http://127.0.0.1:9000')
  if(request.method === 'GET' && urlObj.pathname === '/reg') {
    response.end('注册页面')
    return
  }

  response.end('找不到资源')
})

server.listen(9000, () => {
  console.log('监听中')
})